package com.cdk8s.tkey.management;

import com.cdk8s.tkey.client.rest.EnableTkeySso;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;


@EnableTkeySso
@EnableTransactionManagement
@EnableAsync
@ServletComponentScan
@tk.mybatis.spring.annotation.MapperScan(basePackages = {"com.cdk8s.tkey.management.mapper"})
@Slf4j
@SpringBootApplication
public class Application implements CommandLineRunner {

    @Value("${server.port:9091}")
    private String serverPort;

    @Value("${server.servlet.context-path:/demo}")
    private String serverContextPath;

    @Value("${management.server.servlet.context-path:/tkey-actuator}")
    private String managementContextPath;

    @Value("${management.server.port:19091}")
    private String managementPort;

    //=================================================================================

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Override
    public void run(String... strings) {
        String prefixURL = "http://manage.sso.baicaowei.cn";

        log.info("=================================Application Startup Success=================================");
        log.info("index >> {}:{}{}", prefixURL, serverPort, serverContextPath);
        log.info("client detail >> {}:{}{}/api/client/detail?id=1", prefixURL, serverPort, serverContextPath);
        log.info("swagger >> {}:{}{}/swagger-ui.html", prefixURL, serverPort, serverContextPath);
        log.info("actuator-health >> {}:{}{}/actuator/health", prefixURL, managementPort, managementContextPath);
        log.info("=================================Application Startup Success=================================");
    }
}
